package keeto.com.vn.bms.network.task;

import java.io.IOException;

import keeto.com.vn.bms.config.IBMSCore;
import keeto.com.vn.bms.network.request.GetScheduleRequest;
import keeto.com.vn.bms.network.response.GetScheduleResponse;
import keeto.com.vn.bms.utils.BMSListener;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;

import android.util.Log;

public class TaskGetSchedule extends AbstractTask{
	String authenKey;
	public TaskGetSchedule(BMSListener listener, IBMSCore core,String authenKey) {
		super(listener, core);
		this.authenKey = authenKey;
	}

	
	@Override
	public void run() throws ClientProtocolException, JSONException, IOException {
		GetScheduleRequest request = new GetScheduleRequest();
		request.setAuthenKey(authenKey);
		GetScheduleResponse response = protocol.getSchedule(request);
		for (BMSListener mlistener : listener){
			mlistener.finishGetSchedule(response.getReturnCode(), response.getResultMsg(), response.getListSchedule());
		}
	}

	@Override
	public void timeoutCallback() {
		for (BMSListener mlistener : listener){
			mlistener.finishGetSchedule(protocol.STATUS_CODE_GENERIC_FAIL_CONECTTION, "", null);
		}
	}

}
